
(function(W, D, $){

    W.LIM = {
        active: 0,
        handler: [function(){}, function(){}, function(){}]
    };
    var X, Y, x, y;

    $(D).on('mousemove touchmove', function (e) {
        if (LIM.active) {
            x = e.pageX || e.originalEvent.targetTouches[0].pageX;
            y = e.pageY || e.originalEvent.targetTouches[0].pageY;
            LIM.handler[0](x - X, y - Y, x, y);
        }
    }).on('mouseup touchend', function (e) {
        if (LIM.active) {
            LIM.events[1](x - X, y - Y);
            x = y = X = Y = null;
            LIM.active = 0;
        }
    });


    //计时器
    var timer = new function () {
        var ts, te;
        this.start = function () { ts = new Date().getTime() };
        this.end = function () { te = new Date().getTime(); return te - ts };
    };



    LIM.swipe = function (e) {
        X = e.pageX || e.originalEvent.targetTouches[0].pageX;
        Y = e.pageY || e.originalEvent.targetTouches[0].pageY;
        timer.start();    //记录开始
        LIM.active = 1;
        LIM.handler[2](X, Y);



    };

}(window,document,jQuery));